<template>
  <div class="">
    <template v-for="btn in buttons">
      <el-button :is="getComponent(btn.is)"
                 :index="index"
                 :url="url"
                 size="small"
                 v-bind="getAttrs(btn.attrs)"
                 @click="()=>{btn.click(row)}"
      >{{btn.title}}</el-button>
    </template>
  </div>
</template>
<script >
  import util from "@/utils/util";

  export default {
    name: 'BaseTableAction',
    props:{
      index: Number ,
      url: "" ,
      row: Object ,
      column: {
        type: Object ,
        required: true
      },
      fields:{
        type: Array ,
        default:()=>[]
      }
    },
    computed:{
      buttons(){
        return this.column.buttons || []
      }
    },
    data(){
      return {

      }
    },
    methods:{
      getAttrs(attrs = {}){
        return Object.assign(attrs , this.$attrs)
      },
      getComponent(is){
        if(util.isEmpty(is)){
          return 'el-button'
        }
        return is ;
      }
    }
  }
</script>

<style scoped>

</style>
